<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>随机抽奖</title>
    <style>
        * {
            margin: 0;
            padding: 0
        }
        
        body {
            font-size: 12px;
        }
        
        .result dt,
        .result dd {
            float: left;
            margin: 10px;
        }
        
        .xname {
            height: 30px;
            margin: 30px;
            font-size: 20px;
            font-weight: bold;
            color: #c50000
        }
    </style>
    <script src="jquery.js"></script>

</head>

<body>
    <div class="mt30 ml">
        <select class="mr20 jxsz">
            <option>第一名</option>
            <option>第二名</option>
            <option>第三名</option>
        </select>
        <a href="" title="" class="beginclick mr c_red">begin</a>
        <a href="" title="" class="endclick c_red">end</a>
    </div>

    <h2 class="xname"></h2>

    <dl class="result clearfix">
        <dt>一等奖得主</dt>

    </dl>
    <dl class="result clearfix">
        <dt>二等奖得主</dt>

    </dl>
    <dl class="result clearfix">
        <dt>三等奖得主</dt>

    </dl>



</body>
<script>
    $(function(){

  var auto;
  var arry; 
  function funa(){
    arry=["111","222","333","444","555","666","777","888","999","aaa","bbb","ccc","ddd","eee","fff"];     //定义数组储存姓名
    var rand=Math.floor(Math.random()*arry.length);   
    $(".xname").text(arry[rand]);
     auto=setTimeout(funa,100)
    }
  $(".beginclick").click(function(){
      auto=setTimeout(funa,100)
      return false;
  })
    var aleady;
    $(".endclick").click(function(){
      clearTimeout(auto);
   var szname=$(".xname").text();
   var jx=$(".jxsz")[0].options.selectedIndex;   
   var nowdd=$(".result").eq(jx).find("dd");
   var mm=nowdd.length;
   
   if(mm==jx+1){
        alert("此奖项人选已定!")    
    }else{         
         $(".result").eq(jx).append("<dd>"+szname+"</dd>");
        arry.splice($.inArray(szname,arry),1);   
     }  
   return false;
  })
})

</script>

</html>